<template>
	<view class="music-list">
		<view class="right">
			<text>歌曲列表</text>
			<u-cell-group class="music-list0" title="岛菌最爱">
				<u-cell-item v-for="(item,index) in music0" :title="item.title" :label="item.author" :arrow="false" @click="player(index)" :value="(index===nowPlayer)?'正在播放':''"></u-cell-item>
			</u-cell-group>
			<u-cell-group class="music-list1" title="岛菌的曲">
				<u-cell-item v-for="(item,index) in music1" :title="item.title" :label="item.author" :arrow="false" @click="player(index+music0.length)" :value="(index+music0.length===nowPlayer)?'正在播放':''" ></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	export default {
		name:"music-list",
		props:{
			musicList:{
				type:Array
			},
			nowPlayer:{
				type:Number,
				default:0
			}
		},
		data() {
			return {
				music0:[],
				music1:[],
			};
		},
		
		created() {
			for(var i in this.musicList){
				if(this.musicList[i].type == 1){
					this.music1.push(this.musicList[i])
				}else{
					this.music0.push(this.musicList[i])
				}
			}
		},
		methods:{
			player(index){
				this.$emit("changePlayer",index)
			}
		}
	}
</script>

<style lang="scss">
	
	.music-list{
		display: flex;
		flex-direction: row;
		height: 100%;
		width: 100%;
		padding: 20rpx;
		position: relative;
	
		//border: 2rpx red solid;
		.right{
			width: 100%;
			height: 100%;
			display: flex;
			flex-direction: column;
			//justify-content: center;
			align-items: center;
			text{
				color: $my-text-color1;
				font-size: 32rpx;
			}
		}
	}
</style>
